package com.zy.cat.entity.run.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.zy.cat.entity.run.DailyStepHistory;

public interface DailyStepHistoryRepository extends JpaSpecificationExecutor<DailyStepHistory>,  JpaRepository<DailyStepHistory, String> {
	DailyStepHistory findByPidAndCtimeAndDstatus(String pid,String ctime,int dstatus);
	
	
	/**
	 * 
	 * @info 获取每日运动总步数
	 * @author Link
	 * @date 2019-11-30 15:41
	 * @param pid
	 * @return
	 */
	@Query(nativeQuery = true,value="select SUM(steps)steps from zy_cat_run_step_history where pid=:pid and ctime=CURDATE() and dstatus=1")
	Integer getDailySteps(String pid);
}
